﻿using Auth.Api.Models;

namespace Auth.Api.Data;

public class UserRepository : IUserRepository
{
    private readonly UserContext _context;

    public UserRepository(UserContext context)
    {
        _context = context;
    }


    public User CreateUser(User user)
    {
        _context.Users.Add(user);

        _context.SaveChanges();

        return user;
    }


    public User GetUserByEmail(string email)
    {
        return _context.Users.FirstOrDefault(u => u.Email == email);
    }


    public User GetUserById(int id)
    {
        return _context.Users.FirstOrDefault(u => u.Id == id);
    }

}